import { PaginationProps } from "@pureadmin/table";
export class CommonUtils {
  // static fillPaginationParams(
  //   baseQuery: BasePageQuery,
  //   pagination: PaginationProps
  // ) {
  //   baseQuery.pageNum = pagination.currentPage;
  //   baseQuery.pageSize = pagination.pageSize;
  // }
  static base64ToBlob(base64String, mimeType = 'image/jpeg'): Blob{
    // 将base64字符串中的dataURL头部信息去掉，只保留纯base64编码数据
    const base64WithoutPrefix = base64String.replace(/^data:image\/\w+;base64,/, '');

    // 使用atob将base64编码转换为二进制数据
    const binaryData = atob(base64WithoutPrefix);

    // 构建Blob对象，mimeType根据实际情况调整
    const arrayBuffer = new ArrayBuffer(binaryData.length);
    const uint8Array = new Uint8Array(arrayBuffer);

    for (let i = 0; i < binaryData.length; i++) {
      uint8Array[i] = binaryData.charCodeAt(i);
    }

    return new Blob([arrayBuffer], { type: mimeType });
  }
  // 私有构造函数，防止类被实例化
  private constructor() { }
}